// 通过表单项生成初始值对象
export const getInitialFieldsValue = (list) => {
  const obj = {}
  list.flat().forEach(({ prop, type, mode, multiple, defaultValue }) => {
    const isMultiple = multiple || ['check'].includes(type)
    const isSingle = !mode || mode === 'single'
    const isMultipleDate = type === 'calendar' && !isSingle
    // const isRange = ['calendar'].includes(type)
    if (isMultipleDate || isMultiple) {
      obj[prop] = []
    } else if (['number', 'select'].includes(type)) {
      obj[prop] = defaultValue
    } else {
      obj[prop] = typeof defaultValue !== 'undefined' ? defaultValue : ''
    }
  });
  return obj
}
